package fr.channel.client;

import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.SimpleEventBus;
import com.google.gwt.inject.client.AbstractGinModule;
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.place.shared.PlaceHistoryMapper;
import com.google.inject.Provides;
import com.google.inject.Singleton;

import fr.channel.client.activity.MainActivityMapper;
import fr.channel.client.metier.SmChannel;
import fr.channel.client.metier.impl.SmChannelImpl;
import fr.channel.client.place.MainPlaceHistoryMapper;
import fr.channel.client.view.AttenteView;
import fr.channel.client.view.ConnectionView;
import fr.channel.client.view.impl.AttenteViewImpl;
import fr.channel.client.view.impl.ConnectionViewImpl;

/**
 * Definit les implementations a utiliser.
 * 
 * @author Matthieu
 * 
 */
public class MainModule extends AbstractGinModule {

	@Override
	protected final void configure() {
		bind(ConnectionView.class).to(ConnectionViewImpl.class).in(Singleton.class);
		bind(AttenteView.class).to(AttenteViewImpl.class).in(Singleton.class);
		bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
		bind(ClientFactory.class).to(ClientFactoryImpl.class).in(Singleton.class);
		bind(ActivityMapper.class).to(MainActivityMapper.class).in(Singleton.class);
		bind(PlaceHistoryMapper.class).to(MainPlaceHistoryMapper.class).in(Singleton.class);
		bind(SmChannel.class).to(SmChannelImpl.class).in(Singleton.class);
	}

	/** Provider.
	 * @param eventBus un bus d'evenement
	 * @return un PlaceController correctement initialise
	 */
	@Provides
	protected final PlaceController providePlaceController(final EventBus eventBus) {
		PlaceController result = new PlaceController(eventBus);
		return result;
	}

}
